#e[Stage]
#Title[GIGA SERIOUS]
#Text[



Trial2]
#Image[]
#Player[.\player_psy\psy.txt]
#ScriptVersion[2]

script_stage_main
{
	let ix		=GetClipMinX;
	let mx		=GetClipMaxX;
	let iy		=GetClipMinY;
	let my		=GetClipMaxY;
	let cx		=GetCenterX;
	let cy		=GetCenterY;
	let nx		=0;
	let ny		=0;
	let GP		=0;
	let BS		=0;
	let BS_S	=0;
	let yyA		=0;
	let yyB		=0;
	let yyC		=0;
	let BGS01	=5;
	let BGS02	=3;
	let BGS03	=2;
	let BGC		=false;
	let D		=0;
	let po		=0;
	let Alpha_result=0;
	let AlphaCount	=0;
	let Alpha_tm	=0;
	let Alpha_tmb	=255;
	let pBonus	=0;
	let Point	=0;
	let GameStart	=0;
	let stage	=0;
	let Result	=false;
	let mCount	=0;
	let jiki	=0;
	let s		=3000;//e
	let csd		=GetCurrentScriptDirectory;
	let BG1_1	=csd~"\bg\BG1_1.png";
	let BG1_2	=csd~"\bg\BG1_2.png";
	let BG1_3	=csd~"\bg\BG1_3.png";
	let BG2_1	=csd~"\bg\BG2_1.png";
	let BG2_2l	=csd~"\bg\BG2_2l.png";
	let BG2_2r	=csd~"\bg\BG2_2r.png";
	let BG2_3	=csd~"\bg\BG2_3.png";
	let BG3_1	=csd~"\bg\BG3_1.png";
	let BG3_2	=csd~"\bg\BG3_2.png";
	let BG4_1	=csd~"\bg\BG4_1.png";
	let BG4_2	=csd~"\bg\BG4_2.png";

	let B_11	=csd~"\boss\tewi\img\maho1.png";
	let B_12	=csd~"\boss\tewi\img\maho2.png";

	let bgm1	=csd~"\BGM\bgm1.wav";
	let bgm2	=csd~"\BGM\bgm2.wav";
	let bgm3	=csd~"\BGM\bgm3.wav";
	let bgm4	=csd~"\BGM\bgm4.wav";
	let bgm5	=csd~"\BGM\bgm5.wav";
	let bgm6	=csd~"\BGM\bgm6.wav";
	let imgEnemy1	=csd~"\zako\img\yosei1.png";
	let imgEnemy2	=csd~"\zako\img\yosei2.png";
	let imgEnemy3	=csd~"\zako\img\yosei3.png";
	let imgEnemy4	=csd~"\zako\img\yosei4.png";
	let imgEnemy5	=csd~"\zako\img\yosei5.png";
	let imgresult	=csd~"\bg\clear.png";
	let imgmh	=csd~"\zako\img\mh.png";
	let imgrate	=csd~"\data\img\rate.png";
	let BG_t	=csd~"\data\img\BG_t.png";
	let BG_t2	=csd~"\data\img\BG_t2.png";
	let taitle	=csd~"\data\img\taitle_p.png";
	let taitle_m	=csd~"\data\img\taitle_m.png";
	let taitle_mb	=csd~"\data\img\taitle_mb.png";
	let taitle_ps	=csd~"\data\img\taitle_ps.png";
	#include_function csd~".\data\zako_f.txt"
	#include_function csd~".\data\taitle.txt"
	//#include_function csd~".\data\Result.txt"
	@Initialize()
	{
		ExpertEx(false,1,3);
		SetCommonData(jiki,0);
		SetRateScoreSystemEnable(false);
		LoadGraphic(imgEnemy1);
		LoadGraphic(imgEnemy2);
		LoadGraphic(imgEnemy3);
		LoadGraphic(imgEnemy4);
		LoadGraphic(imgEnemy5);
		LoadGraphic(imgrate);
		LoadGraphic(imgmh);
		LoadGraphic(taitle);
		LoadGraphic(taitle_m);
		LoadGraphic(taitle_mb);
		LoadGraphic(taitle_ps);
		LoadGraphic(BG1_1);
		LoadGraphic(BG1_2);
		LoadGraphic(BG1_3);
		LoadGraphic(BG2_2l);
		LoadGraphic(BG2_2r);
		LoadGraphic(BG2_3);
		LoadGraphic(BG_t);
		LoadGraphic(BG_t2);
		LoadGraphic(B_11);
		LoadGraphic(B_12);
		LoadMusic(bgm1);
		LoadMusic(bgm2);
		TMain;
		}

	task TMain{
	yield;
	Taitle;
	alp_t;
	//S;
	StageTask;
	}

	sub Taitle{
	loop(51){
	Alpha_tm+=5;
	yield;
	}
	loop{
	yield;
	if(GetKeyState(VK_SHOT)==KEY_PUSH||GetKeyState(VK_SHOT)==KEY_HOLD){break;}
	}
	loop(51){
	Alpha_tm-=5;
	Alpha_tmb-=5;
	yield;
	}
	ForbidShot(true);
	loop{
	yield;
	if(GameStart==0){
	TAITLE_KEY;
	SetPlayerX(cx);
	SetPlayerY(cy+160);
	}
	if(GameStart==1){
	DeleteGraphic(BG_t2);
	break;
	Compile;
	}
	}
	}

	task Compile{

	/*CompileEnemyFromFile(csd~"\zako\normal\Z01.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z02.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z03.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z04.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z07.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z08.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z09.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z10.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z11.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z12.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z13.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z14.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z15.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z16.txt");*/


	/*CompileEnemyFromFile(csd~"\zako\normal\Z01.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z02.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z03.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z04.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z07.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z08.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z09.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z10.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z11.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z12.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z13.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z14.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z15.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z16.txt");*/


	/*CompileEnemyFromFile(csd~"\zako\normal\Z01.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z02.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z03.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z04.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z07.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z08.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z09.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z10.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z11.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z12.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z13.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z14.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z15.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z16.txt");*/


	/*CompileEnemyFromFile(csd~"\zako\normal\Z01.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z02.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z03.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z04.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z07.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z08.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z09.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z10.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z11.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z12.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z13.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z14.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z15.txt");
	CompileEnemyFromFile(csd~"\zako\normal\Z16.txt");*/

	}

	function wait(let frame)
	{
			loop(frame){yield};
	}

	function waitForZeroEnemy()
	{
			while(GetEnemyNum() != 0){yield;}
	}

	function RealToIntString(let num){
	if(num<0){num=0;}
	let stringarray=["0","1","2","3","4","5","6","7","8","9"];
	let lp=floor(log10(num))+1;
	let lp1=lp;
	if(lp<=0){result="0"}
	else{
	result = "";
	loop(lp){
	result=result~ stringarray[(num%(10^lp1)-num%(10^(lp1-1)))/(10^(lp1-1))];
	lp1--;
	}
	}
	}	

	task StageTask
	{
	wait(30);
	ForbidShot(false);
	wait(30);
	PlayMusic(bgm1);
	loop(102){
	Alpha_BG_12+=2.5;
	Alpha_BG_11+=2.5;
	yield;
	}
	wait(30);
	if(NORMAL==1){
	#include_function ".\data\stage1.txt"
	//NextStage();
	//#include_function ".\data\stage2.txt"
	//NextStage();
	//#include_function ".\data\stage3.txt"
	//NextStage();
	}
	//else if(EXTRA==1){
	//#include_function ".\data\stage4.txt"
	//NextStage();
	//}
	}

	task S{
	loop{
	yield;
	if(GetEnemyShotCount>s){
	Slow(GetEnemyShotCount/(s)-0.1);
	}
	else{Slow(0)}
	}
	}

	@MainLoop()
	{
		yield;
		ForbidBomb(true);
		mCount++;
	if(REI==1){
	SetCommonData(jiki,1);
	}
	if(SAKU==1){
	SetCommonData(jiki,2);
	}
	if(MARI==1){
	SetCommonData(jiki,3);
	}
	}



	@DrawTopObject{
	if(Alpha_t<=255){ICO;}
	SetGraphicRect(0,0,384,448);
	SetTexture(taitle_mb);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_tmb);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	SetGraphicRect(0,0,384,448);
	SetTexture(taitle_m);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_tm);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	/*if(Result==true){
	SetGraphicRect(0,0,384,449);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_result);
	SetTexture(imgresult);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	DrawText("POINT BOUNS	",		cx-160,	cy-20,20,Alpha_result);
	DrawText("TOTAL BOUNS	",		cx-160,	cy+60,20,Alpha_result);
	DrawText(""~RealToIntString(GP)~"",	cx-20,	cy-20,20,Alpha_result);
	DrawText(""~RealToIntString(GP)~"",	cx-20,	cy+60,20,Alpha_result);
	}*/
	//DrawText(GetCommonData(jiki_ix),		cx-120,	cy-10,10,255);
	//DrawText(MARI,		cx-120,	cy-40,10,255);
	//DrawText(SAKU,		cx-120,	cy-70,10,255);
	//DrawText(GetCommonData(buzz_common),		cx-160,	cy-30,10,255);
	}


	@Finalize()
	{
		DeleteGraphic(imgEnemy1);
		DeleteGraphic(imgEnemy2);
		DeleteGraphic(imgEnemy3);
		DeleteGraphic(imgEnemy4);
		DeleteGraphic(imgEnemy5);
		DeleteGraphic(imgmh);
	}
	let BG_k	=0;
	let BG11_y	=0;
	let BG12_y	=0;
	let BG13_y	=0;
	let BG21_y	=0;
	let BG22_y	=0;
	let BG31_y	=0;
	let BG32_y	=0;
	let kkdi_11	=1;
	let kkdi_12	=1;
	let kkdi_21	=0.1;
	let Alpha_BG_11	=0;
	let Alpha_BG_12	=0;
	let Alpha_BG_21	=0;
	let Alpha_BG_31	=0;


	@BackGround {
	if(GameStart==1){

	BG11_y	=-2;
	BG12_y	=-3;
	BG13_y	=-1.5;
	let nY2 = (mCount * BG13_y)%512;
	SetGraphicRect(0,nY2,384,512+nY2);
	SetTexture(BG1_3);
	SetGraphicScale(kkdi_11,kkdi_11);
	SetAlpha(Alpha_BG_11);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	let nY2 = (mCount * BG11_y)%512;
	SetGraphicRect(0,nY2,384,512+nY2);
        SetTexture(BG1_1);
	SetGraphicScale(kkdi_11,kkdi_11);
	SetAlpha(Alpha_BG_11);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	let nY2 = (mCount * BG12_y)%512;
	SetGraphicRect(0,nY2,384,512+nY2);
	SetTexture(BG1_2);
	SetGraphicScale(kkdi_12,kkdi_12);
	SetAlpha(Alpha_BG_12);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );

	BG2a;//ʂ̍Ẽc̃^XN

	BG21_y	=-4;
	let nY21 = (mCount * BG21_y)%512;
	SetGraphicRect(0,nY21,384,512+nY21);
	SetTexture(BG2_3);
	SetGraphicScale(2,2);
	SetAlpha(Alpha_BG_21*0.6);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );

	BG31_y	=-9;
	BG32_y	=-2;
	let nY31 = (mCount * BG31_y)%512;
	SetGraphicRect(0,nY31,384,512+nY31);
	SetTexture(BG3_1);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_BG_31);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	let nY32 = (mCount * BG32_y)%512;
	SetGraphicRect(0,nY32,384,512+nY32);
	SetTexture(BG3_2);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_BG_31);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );

	/*else if(stage==4){
	BG1_y	=-9;
	BG2_y	=0;
	let nY1 = (mCount * BG1_y)%512;
	SetGraphicRect(0,nY1,384,512+nY1);
	SetTexture(BG4_2);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_BG);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	let nY2 = (mCount * BG2_y)%512;
	SetGraphicRect(0,nY2,384,512+nY2);
	SetTexture(BG4_1);
	SetGraphicScale(1,1);
	SetAlpha(Alpha_BG);
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX, GetCenterY );
	}*/
	}
	}

task BG2a{
	BG21_y	=-2;
	let BG2c=0;
	let c =4;
	loop(c){
	BG2c+=1/c;
	let nY21 = (mCount * BG21_y*BG2c)%512;
	SetGraphicRect(0,nY21,372,5120+nY21);
	SetTexture(BG2_2l);
	SetGraphicScale(kkdi_21,kkdi_21);
	SetAlpha(Alpha_BG_21);
	SetColor((200*BG2c),(200*BG2c),(200*BG2c));
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX+(60-(BG2c*90)), GetCenterY );
	SetGraphicRect(0,nY21,372,5120+nY21);
	SetTexture(BG2_2r);
	SetGraphicScale(kkdi_21,kkdi_21);
	SetAlpha(Alpha_BG_21);
	SetColor((200*BG2c),(200*BG2c),(200*BG2c));
	SetGraphicAngle(0,0,0);
	DrawGraphic( GetCenterX-(60-(BG2c*90)), GetCenterY );
	}

}


	}